package com.wei.duowan.bbs.widget;

import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.wei.duowan.bbs.App;
import com.wei.duowan.bbs.R;

/**
 * 作者：赵若位
 * 时间：2019/10/9 21:05
 * 联系方式：1070138445
 * 功能：
 */
public class NewsChannelItemDecoration extends RecyclerView.ItemDecoration
{

    public NewsChannelItemDecoration()
    {

    }


    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state)
    {
        super.getItemOffsets(outRect, view, parent, state);
        RecyclerView.LayoutManager manager = parent.getLayoutManager();
        if (manager instanceof GridLayoutManager)
        {
            int position = manager.getPosition(view);
            if (position == 0)
            {
                outRect.top = App.getResource().getDimensionPixelSize(R.dimen.dp_11);
            }
        }
    }
}
